#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;


class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        if(s.empty())
            return 0;
        int max=1;
        for(int i=0;i<s.size();i++)
        {
            int start = i;
            unordered_set<char> tmp;
            while(start<s.size())
            {
                if(tmp.find(s[start])==tmp.end())
                {
                    tmp.insert(s[start]);
                    start++;
                    if(tmp.size()>max)
                        max = tmp.size();
                }
                else
                {
                    tmp.clear();
                    break;
                }
            }
        }
        return max;
    }
};